package sf.r2dbc.rowmapper;

import io.r2dbc.spi.ColumnMetadata;
import io.r2dbc.spi.Row;
import io.r2dbc.spi.RowMetadata;

import java.util.ArrayList;
import java.util.List;


/**
 * 结果集转为list
 */
public class R2dbcListRowMapper implements R2dbcRowMapper<List<Object>> {
    @Override
    public List<Object> apply(Row rs, RowMetadata metadata) {
        List<Object> result = new ArrayList<>();
        for (ColumnMetadata cmd : metadata.getColumnMetadatas()) {
            String columnName = cmd.getName();
            result.add(rs.get(columnName));
        }
        return result;
    }

}
